package com.mycompany.goodsys.core.AddGood;

import com.mycompany.goodsys.core.AppEntity.AppEntity;
import com.mycompany.goodsys.core.AppEntity.AppObj;

public class AddGoodData {
    static String name = "";
    static String number = "";
    static String message = "";

    public static void Init() {
        name = "";
        number = "";
        message = "";
    }

    public static void SetInfo(String key) {
        if(name == ""){
            name = key;
            message = message + "添加对象属性 name: " + name + "\n";
        } else if(number == ""){
            number = key;
            message = message + " number: " + number + "\n";

            AppObj obj = new AppObj(name,number);
            boolean is_succ = AppEntity.AddObj(obj);

            Init();
            message = is_succ ? "成功添加一个对象" : "添加对象失败";
            message = message + " ： name: " + obj.GetName() + "  number: " + obj.GetNumber() + "\n";
        }
    }

    public static String GetInfo(){
        String val = message;

        if(name == ""){
            val = val + "请输入 属性 name :";
        }else if(number == ""){
            val = val + "请输入 属性 number : ";
        }
        return val;
    }
}
